﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
    <link href="/lib/easyui/default/easyui.css" rel="stylesheet" />
    <script type="text/javascript" src="/lib/easyui/jquery.easyui.min.js"></script>
    <title>收款匹配查询</title>
</head>
<body style="background-color: white;">
    <div class="data-wrap case">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline ">
            </div>
            <div class="pull-right">
                <form class="form-inline" id="formSearch" onsubmit="return false;">
                    <div class="input-group input-group-sm">
                        <div class="input-sm">
                            <input id="matchTranstype" type="checkbox" title="不匹配交易类型" autocomplete="off" />
                            <label class="wd100">不匹配交易类型</label>
                        </div>
                    </div>
                    <div class="input-group input-group-sm">
                        <div class="input-sm">
                            <input id="matchClientAccountName" type="checkbox" title="不匹配客户姓名" autocomplete="off" />
                            <label class="wd100">不匹配客户姓名</label>
                        </div>
                    </div>
                    <div class="input-group input-group-sm">
                        <div class="input-sm">
                            <input id="matchBalance" type="checkbox" title="不匹配金额" autocomplete="off" />
                            <label class="wd100">不匹配金额</label>
                        </div>
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon">匹配时间(分)：</label>
                        <input class="form-control" name="minutes" id="minutes" type="text" maxlength="5" autocomplete="off" placeholder="介于 -1440 和 1440 之间" />
                    </div>
                    <button type="button" class="btn btn-default btn-sm active" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                </form>
            </div>
        </div>
        <div class="data-easyui data-scroll">
            <div class="data-view">
                <div class="data-div-view table-responsive">
                    <table class="easyui-datagrid" id="matchSearchRecord"></table>
                </div>
            </div>
        </div>

    </div>
    <script src="/js/page/matchsearch.js?v=201903201544"></script>
    <script type="text/javascript">
    var matchId = 0;

    $(function () {

        matchId = FlashPay.Util.GetQueryString("Id");

        doSearch(matchId);

        //搜索
        $("#btnSearch").click(function () {
            let minutes = $("#minutes").val();

            if (minutes < -1440 || minutes > 1440) {
                FlashPay.UI.Tip_short_warning("请输入-1440至1440之间的数字");
                return;
            }
            doSearch(matchId);
        })
        //切换checkbox
        $("#matchBalance,#matchTranstype,#matchClientAccountName").click(function () {
            doSearch(matchId);
        })
    })

    function doSearch(matchId) {

        var queryParams = {
            Id: matchId
        };

        let matchTranstype = $("#matchTranstype").is(':checked');
        if (matchTranstype) {
            queryParams.MatchTranstype = 0;
        }

        let matchClientAccountName = $("#matchClientAccountName").is(':checked');
        if (matchClientAccountName) {
            queryParams.MatchClientAccountName = 0;
        }

        let matchBalance = $("#matchBalance").is(':checked');
        if (matchBalance) {
            queryParams.MatchBalance = 0;
        }

        let minutes = $("#minutes").val();
        if (!FlashPay.Util.isNullOrEmptySpance(minutes)) {
            queryParams.Minutes = minutes;
        }

        $("#matchSearchRecord").datagrid({
            fit: false,
            loadMsg: '数据加载中，请稍后……',
            method: "post",
            border: true,
            url: "/DepositMatchRecord/GetMatchSearch",
            queryParams: queryParams,
            height: 430,
            singleSelect: true,
            rownumbers: true,
            width: 1170,
            frozenColumns: [[
                {
                    field: 'orderNo',
                    title: '订单号',
                    width: 180,
                    align: 'left',
                    formatter: function (val, item) {
                        var result = val;
                        //return '{1} <a class="btn btn-primary btn-xs" onclick="return bindReceiptRecord(this)" data-content="{0}<br>确定要<span class=red>匹配</span>该收款单？" data-href="/DepositMatchRecord/ReceiptMatchRecordBindReceiptRecord?Id={0}&orderNo={1}">匹配</a>'.format(matchId, val);
                        result += ' <button type="button" class="btn btn-primary btn-xs" data-modal="/view/receipt/matchconfirm.html?id={0}&orderNo={1}" data-title="匹配确认" data-confirmname="确认" data-width="400" data-height="150"><span class="glyphicon glyphicon-edit"></span> 匹配</button>'.format(matchId, val);
                        return result;
                    }
                },
                { field: 'companyName', title: '公司名称', width: 100, align: 'left' },
                { field: 'withdrawalOrderNo', title: '收款单号', width: 180, align: 'left' }
            ]],
            columns: [[
                { field: 'bankName', title: '收款银行', width: 65, align: 'left' },
                { field: 'cardName', title: '收款姓名', width: 65, align: 'left' },
                { field: 'cardNumber', title: '收款卡号', width: 120, align: 'left' },
                {
                    field: 'createDbdate',
                    title: '创建时间',
                    width: 120,
                    align: 'left',
                    formatter: function (val, row) {
                        return FlashPay.Util.FormatDate(val);
                    }
                },
                {
                    field: 'withdrawalAmount',
                    title: '收款金额',
                    width: 65,
                    align: 'right',
                    formatter: function (val, row) {
                        return '<span class="bold">{0}</span>'.format(val);
                    }
                },
                {
                    field: 'depositDate',
                    title: '收款时间',
                    width: 120,
                    align: 'left',
                    formatter: function (val, row) {
                        return FlashPay.Util.FormatDate(val);
                    }
                },
                {
                    field: 'depositType',
                    title: '交易类型',
                    width: 100,
                    align: 'left',
                    formatter: function (val, row) {
                        return val;
                    }
                },
                {
                    field: 'noticeStatus',
                    title: '通知状态',
                    width: 125,
                    align: 'left',
                    formatter: function (val, row) {
                        var returnStr = "";
                        if (val == 1) {
                            returnStr = "<span class='bold'>未通知</span>";
                        } else if (val == 2) {
                            returnStr = '<span class="green bold">通知成功</span>';
                        } else if (val == 3) {
                            returnStr = "<span class='red bold'>通知失败</span>";
                        } else if (val == 4) {
                            returnStr = "<span class='orange bold'>通知中</span>";
                        } else if (val == 5) {
                            returnStr = "<span class='bold' >不通知</span>";
                        }
                        return returnStr;
                    }
                },
                {
                    field: 'noticeLastDate',
                    title: '通知时间',
                    width: 120,
                    align: 'left',
                    formatter: function (val, row) {
                        return FlashPay.Util.FormatDate(val);
                    }
                },
                { field: 'noticeTimes', title: '通知次数', width: 75, align: 'left' },
                { field: 'withdrawalAccountName', title: '客户姓名', width: 75, align: 'left' },
                { field: 'withdrawalBankName', title: '客户银行', width: 150, align: 'left' },
                { field: 'withdrawalCardNumber', title: '客户卡号', width: 200, align: 'left' },
                { field: 'postScript', title: '客户附言', width: 200, align: 'left' }
            ]]
        });
    }

    function bindReceiptRecord(obj) {

        FlashPay.UI.Confirm({
            content: $(obj).data("content"),
            ok: function () {

                FlashPay.Util.Ajax({
                    type: "POST",
                    url: $(obj).data("href"),
                    success: function (res) {
                        if (res.success) {
                            FlashPay.UI.DialogOpener().Tip_success(res.successMessage);
                            FlashPay.UI.DialogOpener().doSearch();
                            setTimeout(function () {
                                FlashPay.UI.CloseDialog();
                            }, 1000);
                        } else {
                            FlashPay.UI.Tip_warning("删除失败：" + res.errorMessage);
                        }
                    },
                    error: function (e) {
                        FlashPay.UI.Tip_warning("网络请求失败！");
                    }
                });

            }
        });
    }

    function closeParent(res) {

        FlashPay.UI.CloseDialog();

        FlashPay.UI.DialogOpener().Tip_success(res.successMessage);
        FlashPay.UI.DialogOpener().doSearch();
    }
    </script>
</body>
</html>